//
//  StatusBottomCell.swift
//  weibo 666
//
//  Created by mac on 15/11/10.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit

class StatusBottomCell: UIView {
    //构造函数
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //MARK: - 懒加载控件
    ///转发按钮
    private lazy var forwardButton: UIButton = UIButton(title: "转发", fontSize: 12, color: UIColor.lightGrayColor(), imageName: "timeline_icon_retweet")
    /// 评论按钮
    private lazy var commentButton: UIButton = UIButton(title: " 评论",
        fontSize: 12,
        color: UIColor.lightGrayColor(),
        imageName: "timeline_icon_comment")
    /// 转发按钮
    private lazy var likeButton: UIButton = UIButton(title: " 赞",
        fontSize: 12,
        color: UIColor.lightGrayColor(),
        imageName: "timeline_icon_unlike")
    
}
//MARK: - 设置界面
extension StatusBottomCell{
    private func setupUI() {
        // 0. 背景颜色
        backgroundColor = UIColor(white: 0.95, alpha: 1.0)
        
        // 1. 添加控件
        addSubview(forwardButton)
        addSubview(commentButton)
        addSubview(likeButton)
        
        // 2. 自动布局
        forwardButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
        }
        commentButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(forwardButton.snp_right)
            make.top.equalTo(forwardButton.snp_top)
            make.width.equalTo(forwardButton.snp_width)
            make.height.equalTo(forwardButton.snp_height)
        }
        likeButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.top.equalTo(forwardButton.snp_top)
            make.width.equalTo(forwardButton.snp_width)
            make.height.equalTo(forwardButton.snp_height)
            
            make.right.equalTo(self.snp_right)
        }
        
        // 3. 分隔线
        let sep1 = sepView()
        addSubview(sep1)
        let sep2 = sepView()
        addSubview(sep2)
        
        sep1.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(forwardButton.snp_centerY)
            make.left.equalTo(forwardButton.snp_right)
            make.width.equalTo(0.5)
            make.height.equalTo(forwardButton.snp_height).multipliedBy(0.6)
        }
        sep2.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(forwardButton.snp_centerY)
            make.left.equalTo(commentButton.snp_right)
            make.width.equalTo(sep1.snp_width)
            make.height.equalTo(sep1.snp_height)
        }
    }
    
    /// 分隔线视图
    private func sepView() -> UIView {
        let v = UIView()
        v.backgroundColor = UIColor.darkGrayColor()
        
        return v
    }

}
